﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Linkmeme.Views.Shared
{
    public partial class UserProviderList : System.Web.Mvc.ViewUserControl<List<UserSelectedProvider>>
    {
        protected string ViewAllLinkOneController(string groupKey)
        {
            return Html.ActionLink<Linkmeme.Controllers.SourceController>(c => c.ViewAll(groupKey, "Provider"), "查看全部");
        }

        protected string ViewLinkOneController(string groupKey, UserSelectedProvider provider)
        {
            return Html.ActionLink<Linkmeme.Controllers.SourceController>(c => c.View(groupKey, provider.ProviderID, provider.ProviderUserName), "查看");
        }


        protected List<GroupItemData<UserSelectedProvider>> GroupProviderList(List<UserSelectedProvider> providerList)
        {
            var gl = from cp in providerList
                     group cp by cp.ProviderType into groups
                     select new GroupItemData<UserSelectedProvider>
                     {
                         GroupKey = groups.Key,
                         GroupType = "ProviderType",
                         Items = groups.ToList()
                     };
            return gl.ToList();
        }
    }






    //private string ViewLink(string groupKey, UserSelectedProvider provider)
    //{
    //    string link = "";
    //    switch (groupKey)
    //    {
    //        case "photo":
    //            link = Html.ActionLink<Linkmeme.Controllers.PhotoController>(c => c.View(provider.ProviderID, provider.ProviderUserName), "查看");
    //            //link = Html.ActionLink<Linkmeme.Controllers.PhotoController>(c => c.ViewAll("Provider"), "查看全部");
    //            break;
    //        case "blog":
    //            link = Html.ActionLink<Linkmeme.Controllers.BlogController>(c => c.View(provider.ProviderID, provider.ProviderUserName), "查看");
    //            break;
    //        case "bookmark":
    //            link = Html.ActionLink<Linkmeme.Controllers.BookmarkController>(c => c.View(provider.ProviderID, provider.ProviderUserName), "查看");
    //            break;
    //        default:
    //            break;
    //    }
    //    return link;
    //}

    //private string ViewAllLink(string groupKey)
    //{ 
    //    string link = "";
    //    switch (groupKey)
    //    {
    //        case "photo":
    //            link = Html.ActionLink<Linkmeme.Controllers.PhotoController>(c => c.ViewAll("Provider"), "查看全部");
    //            break;
    //        case "blog":
    //            link = Html.ActionLink<Linkmeme.Controllers.BlogController>(c => c.ViewAll("Provider"), "查看全部");
    //            break;
    //        case "bookmark":
    //            link = Html.ActionLink<Linkmeme.Controllers.BookmarkController>(c => c.ViewAll("Provider"), "查看全部");
    //            break;

    //        default:
    //            break;
    //    }
    //    return link;
    //}

}
